home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 February / EnigmA AMIGA RUN 15 (1997)(G.R. Edizioni)(IT)[!][issue 1997-02][PLANET CD V].iso / enigma / earcd / utility / utilwb / mrjquote.lha / mrjQuote2.30 / ARexx / mrjQuote.dopus5 < prev    next >
Text File  |  1996-09-27  |  5KB  |  94 lines

  1. /* mrjQuote ARexx Module for Directory Opus 5.5
  2.    ©1996 Mark Rigby-Jones for mrjsw
  3.    mark.rigby-jones@keble.oxford.ac.uk <*> http://users.ox.ac.uk/~kebl0206/
  4.  
  5. $VER: mrjQuote.opus5 1.1 (21.09.96)
  6.  
  7.    This provides similar functionality to mrjQuote.rexx but as a module for
  8.    Directory Opus 5.5. To use, simply place in your DOpus5:Modules directory,
  9.    no need even to reboot. You'll need to set the three variables at the top
  10.    of the script as neccessary - StartUp should be changed to "yes" if you
  11.    want mrjQuote to be loaded automatically, or a valid command if you want a
  12.    quote to be popped up (or whatever) as well. This script provides two new
  13.    internal commands for DOpus:
  14.     Quote [COMMAND] [<QuoteList>]
  15.     Sig [<SigList>]                  (synonymous with 'Quote Sig [<SigList>]')
  16.    COMMAND can be one of:
  17.     REQ  - Pop up a quote requester [using <QuoteList>]
  18.     SIG  - Generate a .signature    [using <QuoteList>/<SigList>]
  19.     OPEN - Open the preferences GUI
  20.     QUIT - Quit mrjQuote
  21.    If no COMMAND is supplied, then a quote is popped up in a DOpus requester.
  22.    this has similar functionality to REQ, but won't lock up mrjQuote, leaving
  23.    its ARexx port open to other programs.                                   */
  24.  
  25. QuotePort = "QUOTE"       /* Change this if you've altered it in the prefs  */
  26. FileName  = "mrjsw:Quote" /* Put the full path to mrjQuote in here.         */
  27. StartUp   = "no"          /* Load mrjQuote on startup? no/yes or arguments  */
  28.  
  29. Parse Arg DOpusPort Function Source Dest Args  /* Parse command line        */
  30. Parse Var Args ' ' Arg1 ' ' Arg2               /* Parse arguments           */
  31. Options Results                                /* Enable return values      */
  32.  
  33. If Function = "init" Then Do                   /* Module startup            */
  34.     Address Value DOpusPort                    /* Create internal commands  */
  35.     DOpus Command "Quote" Program "mrjQuote" Desc "'Pop up a random quote'" Template "COMMAND,QUOTELIST/F"
  36.     DOpus Command "Sig" Program "mrjQuote" Desc "'Create a random signature'" Template "SIGLIST"
  37.     If StartUp = "no"                          /* Exit if no loading reqest */
  38.         Then Exit
  39.     Parse Var StartUp Arg1 ' ' Arg2            /* Parse default arguments   */
  40.     End
  41.  
  42. If Function = "Sig" Then Do                    /* Command 'Sig <file>'      */
  43.     Arg2 = Arg1                                /*  Convert to:              */
  44.     Arg1 = "Sig"                               /*  'Quote Sig <file>'       */
  45.     End
  46.  
  47. ArgU = Upper(Arg1)                             /* UpperCase copy of command */
  48. Arg2 = Strip(Arg2,,'"')                        /* Strip quotes from file    */
  49.  
  50. If ~Show(P,QuotePort) Then Do                  /* If mrjQuote isn't loaded: */
  51.     If ArgU = "QUIT"                           /* Exit if QUIT was given    */
  52.         Then Exit
  53.     Address "COMMAND"                          /* Send commands to the OS   */
  54.     'Run >NIL: "'FileName'" CDITY AREXX QUIET' /* Otherwise, run it         */
  55.     WaitForPort QuotePort                      /*  and wait for it to load  */
  56.     End
  57.  
  58. Address Value QuotePort                        /* Send commands to mrjQuote */
  59.  
  60. Select
  61.     When ArgU = "YES" Then                     /* For use with startup      */
  62.         Exit              
  63.     When ArgU = "REQ" Then                     /* Pop-up quote              */
  64.         Quote Arg2
  65.     When ArgU = "SIG" Then                     /* Generate .signature       */
  66.         Sig Arg2
  67.     When ArgU = "OPEN" Then                    /* Open the preferences GUI  */
  68.         Open
  69.     When ArgU = "QUIT" Then                    /* Quit mrjQuote             */
  70.         Quit
  71.     Otherwise                                  /* Popup quote using DOpus   */
  72.         RC   = 1
  73.         Arg1 = Strip(Arg1,,'"')                /* Strip quotes from file    */
  74.         Tr1  = XRange('0'x,'FF'x)              /* Set up filter to remove   */
  75.         Tr2  = Overlay("'",Tr1,35)             /*  any "s from the quote    */
  76.         Do While RC = 1                        /* While we want quotes      */
  77.             Reply Arg1                         /*  Generate a quote         */
  78.             If Open(FileHandle,"T:mrjQuote") Then Do
  79.                 Text = Translate(Strip(ReadLn(FileHandle)),Tr2,Tr1)
  80.                 Do While ~EOF(FileHandle)      /* Read in the quote         */
  81.                     Text = Text||'0A'x||Translate(Strip(ReadLn(FileHandle)),Tr2,Tr1)
  82.                     End
  83.                 Call Close(FileHandle)         /* Close the file            */
  84.                 End
  85.             Address Value DOpusPort            /* Pop up a DOpus requester  */
  86.             DOpus Request '"'Text'" Another|OK|Quit'
  87.             Address Value QuotePort
  88.             IF RC = 0                          /* Quit mrjQuote if desired  */
  89.                 Then Quit
  90.         End
  91. End
  92. Exit
  93.  
  94.